package com.ruoyi.lnb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lnb.domain.Userinformation;
import com.ruoyi.lnb.service.IUserinformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户信息管理Controller
 * 
 * @author lnb
 * @date 2022-04-05
 */
@RestController
@RequestMapping("/lnb/userinformation")
public class UserinformationController extends BaseController
{
    @Autowired
    private IUserinformationService userinformationService;

    /**
     * 查询用户信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Userinformation userinformation)
    {
        startPage();
        List<Userinformation> list = userinformationService.selectUserinformationList(userinformation);
        return getDataTable(list);
    }

    /**
     * 导出用户信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:export')")
    @Log(title = "用户信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Userinformation userinformation)
    {
        List<Userinformation> list = userinformationService.selectUserinformationList(userinformation);
        ExcelUtil<Userinformation> util = new ExcelUtil<Userinformation>(Userinformation.class);
        util.exportExcel(response, list, "用户信息管理数据");
    }

    /**
     * 获取用户信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") Long uuid)
    {
        return AjaxResult.success(userinformationService.selectUserinformationByUuid(uuid));
    }

    /**
     * 新增用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:add')")
    @Log(title = "用户信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Userinformation userinformation)
    {
        return toAjax(userinformationService.insertUserinformation(userinformation));
    }

    /**
     * 修改用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:edit')")
    @Log(title = "用户信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Userinformation userinformation)
    {
        return toAjax(userinformationService.updateUserinformation(userinformation));
    }

    /**
     * 删除用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:userinformation:remove')")
    @Log(title = "用户信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable Long[] uuids)
    {
        return toAjax(userinformationService.deleteUserinformationByUuids(uuids));
    }
}
